﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace HostingDomainWebsite
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {

        protected Timer timer = new Timer();

        protected void Page_Load(object sender, EventArgs e)
        {
            //Session["username"] = "thebad";
            if (Session["username"] == null)
            {
                Response.Redirect("AdminLogin.aspx");
            }
            else
            {
                Username.InnerHtml = Session["username"].ToString();
            }
        }

        //Get Message and change css class of it
        public void getMessage(string message, string classStyle)
        {
            divBigNotification.Attributes["class"] = classStyle;
            divBigNotification.Attributes["style"] = "display:block;";
            divNotification.InnerHtml = message;
            timer.Enabled = true;
        }

        //Get Attention Message
        public void getMessageAttention(string message)
        {
            divBigNotification.Attributes["class"] = "notification attention png_bg";
            divBigNotification.Attributes["style"] = "display:block;";
            divNotification.InnerHtml = message;
            timer.Enabled = true;
        }

        //Get Error Message
        public void getMessageError(string message)
        {
            divBigNotification.Attributes["class"] = "notification error png_bg";
            divBigNotification.Attributes["style"] = "display:block;";
            divNotification.InnerHtml = message;
            timer.Enabled = true;
        }

        //Get Success Message
        public void getMessageSuccess(string message)
        {
            divBigNotification.Attributes["class"] = "notification success png_bg";
            divBigNotification.Attributes["style"] = "display:block;";
            divNotification.InnerHtml = message;
            timer.Enabled = true;
        }

        //Get Information Message
        public void getMessageInformation(string message)
        {
            divBigNotification.Attributes["class"] = "notification information png_bg";
            divBigNotification.Attributes["style"] = "display:block;";
            divNotification.InnerHtml = message;
            timer.Enabled = true;
        }

        public void clearNav()
        {
            Account.Attributes["class"] = "nav-top-item";
                AdminPage.Attributes["class"] = "";
                AdminAddition.Attributes["class"] = "";
                ChangePassword.Attributes["class"] = "";

            ServiceManagement.Attributes["class"] = "nav-top-item";
                Services.Attributes["class"] = "";
                CateTitle.Attributes["class"] = "";

            ArticleCategories.Attributes["class"] = "nav-top-item no-submenu";
            OrderManagement.Attributes["class"] = "nav-top-item no-submenu";
            About.Attributes["class"] = "nav-top-item no-submenu";
        }

        protected void Timer_Tick(object sender, EventArgs e)
        {
            divBigNotification.Attributes["style"] = "display:none;";
            divBigNotification.Focus();
            timer.Enabled = false;
        }


        #region [Use for Group has child]
        public void setCurrentNav(string idGroup, string idChild)
        {
            if (idGroup.Equals("Account"))
            {
                Account.Attributes["class"] = "nav-top-item current";
                if (idChild.Equals("AdminPage"))
                {
                    AdminPage.Attributes["class"] = "current";
                }
                else if (idChild.Equals("AdminAddition"))
                {
                    AdminAddition.Attributes["class"] = "current";
                }
                else if (idChild.Equals("ChangePassword"))
                {
                    ChangePassword.Attributes["class"] = "current";
                }
            }
            else if (idGroup.Equals("ServiceManagement"))
            {
                ServiceManagement.Attributes["class"] = "nav-top-item current";
                if (idChild.Equals("Services"))
                {
                    Services.Attributes["class"] = "current";
                }
                else if (idChild.Equals("ServiceTitle"))
                {
                    CateTitle.Attributes["class"] = "current";
                }
            }
            else if (idGroup.Equals("ArticleCategories"))
            {
                ArticleCategories.Attributes["class"] = "nav-top-item no-submenu current";
                if (idChild.Equals("ArticleGroup"))
                {
                    ArticleGroup.Attributes["class"] = "current";
                }
                else if (idChild.Equals("Article"))
                {
                    Article.Attributes["class"] = "current";
                }
                
            }
        }
        #endregion

        #region [Use for Group has no child]
        public void setCurrentNav(string idGroup)
        {            
            if (idGroup.Equals("OrderManagement"))
            {
                OrderManagement.Attributes["class"] = "nav-top-item no-submenu current";
            }
            else if (idGroup.Equals("About"))
            {
                About.Attributes["class"] = "nav-top-item no-submenu current";
            }
        }
        #endregion

        #region [Manageing tabs]
        public void changeNameTab1(string name)
        {
            idTab1.InnerHtml = name;
        }

        public void displayTab1(bool active)
        {
            if (active)
            {
                idTab1.Attributes["style"] = "display:block";
            }
            else
            {
                idTab1.Attributes["style"] = "display:none";
            }
        }
        #endregion

    }
}
